<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>选择列表</title>
		<!--js库及样式-->
		<script LANGUAGE="javascript" src="../script/common.js" type="text/javascript"></script>
		<!--动态js-->
		<script language="javascript" type="text/javascript">
	   		var org = Common.cOrg()
	   		
			var qt = {};
			var qt2 = {};
			var qt3 ={};
			var qt4 ={};
			var b=false;
			function load(){
			    Eui.showNavigation();
			    setPages(["listview","listview2"]);
		     	var r=getPara("id");
				
				    
			 	
			}
			
			function change10(){
			   Common.initSql($("mainform").level200,"org_dj_top",{},"0","1","全 部")
			}
			function change20(){
			   Common.initSql($("mainform").level500,"org_dj_top200",{},"0","1","全 部")
			}
			function change30(){
			   Common.initSql($("mainform").level2001,"org_dj_dq",{},"0","1","全 部")
			   Common.initSql($("mainform").level5001,"org_dj_ds",{},"0","1","全 部")
			   Common.initSql($("mainform").level7001,"org_dj_djd",{},"0","1","全 部")
			}
			var orgidp;
			function change31(s){
			          Common.initSql($("mainform").level5001,"org_dj_ds",{dqid:s},"0","1","全部");   
			          orgidp=s;
			          Common.initSql($("mainform").level7001,"org_dj_djd",{dqid:s},"0","1","全部");	
			}
		function change32(s){
		
			     if(s){
			          Common.initSql($("mainform").level7001,"org_dj_djd",{dsid:s},"0","1","全部");
					DWR.call("giftStorageService.getParentOrg",s,function(v){
						$("level2001").value=v.id;	
					});
				}else if(!s &&!orgidp){
					Common.initSql($("mainform").level7001,"org_dj_djd",{dsid:s},"0","1","全部");
				}else if(!s&&orgidp){
			         
			            Common.initSql($("mainform").level7001,"org_dj_djd",{dqid:orgidp},"0","1","全部");
				}else{
				
				}
			}
			function change33(s){
			     if(s){
			       	DWR.call("giftStorageService.getParentOrg",s,function(v){
			  	
						$("level5001").value=v.id;	
						DWR.call("giftStorageService.getParentOrg",v.id,function(v){
						$("level2001").value=v.id;	
					});
					});
					
			     }
			
			}
			//设置表格数据列
			function createTable(){
				var columns = [];
				columns[6]={title:"操作",width:"9%",align:"center",render:store,order:false}
				qt = new QueryTable("select_org_dj_djd","mainform","datalist",columns);
			
			}
			function createTable3(){
				var columns = [];
				columns[6]={title:"操作",width:"9%",align:"center",render:store,order:false}
				qt3 = new QueryTable("select_org_dj_djd2","mainform","datalist",columns);
			
			}
			function createTable4(){
				var columns = [];
				columns[6]={title:"操作",width:"9%",align:"center",render:store,order:false}
				qt4 = new QueryTable("select_org_dj_djd3","mainform","datalist",columns);
			
			}
			
		    function createTable2(){
				var columns = [];
				qt2 = new QueryTable("gift_location_store","mainform2","datalist2",columns);
			
			}
			function store(v,r){
			 return	"<a href=# onclick=\"lookup("+r[0]+");return false;\">库存查询</a>" 
			
			}
			function lookup(){
		   	createTable2();
			 switchPage('listview2');
			
			}
			
			//显示、刷新表格
			function showData(){
		            if($("A03").checked)
					{  
					 createTable();
					qt.showTable();}
					else if($("A02").checked)
					 	{
					 	createTable3();
					 	qt3.showTable();}
					else if($("A01").checked)
					 	{
					 	createTable4();
					 	qt4.showTable();
					 	}
					 	else{
					 	alert("请选择机构类型");
					 	}					 	
					 			//qt为全局的QueryTable对象
					
			}
			
		   function lookBack(){
				 switchPage('listview');	//qt为全局的QueryTable对象
					
			}
			
			function showData2(){
			        createTable2();
			        qt2.showTable();
			}
			function getBackValue() {
				var obj = qt.getRadioValue(true);
				var v = {id : obj[0],
					name : obj[1]
				}
				return v;
			}
	
			function onSave() {
				var v = getBackValue();
				dialogBackValue(v);
			}
			function a01change(){
			if($("A01").checked){
			change10();
			$("level200").disabled=false;
			$("level500").disabled=true;
		     $("level2001").disabled=true;
			$("level5001").disabled=true;
			$("level7001").disabled=true;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}else if($("A02").checked)
			{
			change20();
			$("level200").disabled=true;
			$("level500").disabled=false;
		     $("level2001").disabled=true;
			$("level5001").disabled=true;
			$("level7001").disabled=true;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}else{
			change30();
			$("level200").disabled=true;
			$("level500").disabled=true;
		     $("level2001").disabled=false;
			$("level5001").disabled=false;
			$("level7001").disabled=false;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}
			}
			
		</script>
	</HEAD>
<BODY class="body" onload="load()">
 <div class=" nav "><div id="nav">&nbsp;</div></div>
 <div id="content"><!--查询静态页面部分-->
	<div id="listview">	
		<!--查询条件form-->
		<div class="form">
			<form id="mainform" name="mainform">
				<input type="hidden" name="orgLocation">
				<input type="hidden" name="locationId">
				<div class="searchForm">
					<table cellSpacing=0 cellPadding=4 width="100%" border=0>
							    <tr><td><input type="radio" name="level" id="A01" onClick="a01change()">总部</input></td>
							        <td><label>兑奖点</label> <select name="level200" disabled></select></td> 
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A02" onClick="a01change()">省大区</input></td>
							    <td ><label>兑奖点</label> <select name="level500" disabled></select></td>
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A03" onClick="a01change()">地市</input></td>
							    <td><label>省大区</label> <select name="level2001" disabled  onClick="change31(this.value)"></select></td>
							    <td><label>地&nbsp;&nbsp;市</label> <select name="level5001" disabled onClick="change32(this.value)"></select></td>
							    <td><label>兑奖点</label> <select name="level7001" disabled onClick="change33(this.value)"></select></td>
					          
						</tr>
						<tr>
							<td></td><td></td><td></td><td></td><td><button type="button" onclick="showData()">查 询</button></td>
						</tr>
					</table>
					</div>
				</table>
			</form>
		</div>
		<div id="datalist"></div>
	</div>
	
	<div id="listview2" style="display:none;">	
		<!--查询条件form-->
		<div class="form">
			<form id="mainform2" name="mainform2">
				<input type="hidden" name="orgLocation">
				<input type="hidden" name="locationId">
				<div class="searchForm">
					<table cellSpacing=0 cellPadding=4 width="100%" border=0>
							
						<tr>
						<td><label>礼品名称</label> <input type="text" name="giftname"  id="giftname" value="" /></td>
						<td><label>礼品编号</label> <input type="text" name="goodsCode"  id="goodsCode" value="" /></td>
						<td><button type="button" onclick="showData2()">查 询</button><button type="button" onclick="lookBack()">返 回</button></td>
						</tr>
					</table>
					</div>
				</table>
			</form>
		</div>
		<div id="datalist2"></div>
	</div>
</BODY>
</HTML>